@mixin box-shadow($color, $fromLeft: true) {
  @if $fromLeft {
    // prettier-ignore
    box-shadow:
      -4px 0,
      4px 0,
      -4px 4px $color,
      0 4px,
      -8px 4px,
      -4px 8px,
      -8px 8px;
  } @else {
    // prettier-ignore
    box-shadow:
      -4px 0,
      4px 0,
      4px 4px $color,
      0 4px,
      8px 4px,
      4px 8px,
      8px 8px;
  }
}

.nes-balloon {
  @include rounded-corners();

  position: relative;
  display: inline-block;
  padding: 1rem 1.5rem;
  margin: 8px;
  margin-bottom: 30px;
  background-color: $background-color;

  > :last-child {
    margin-bottom: 0;
  }

  &::before,
  &::after {
    position: absolute;
    content: "";
  }

  &.is-dark {
    @include rounded-corners(true);

    color: $background-color;
    background: $base-color;
    border-image-outset: 2;
    box-shadow: 0 0 0 8px $base-color;

    &.from-left,
    &.from-right {
      &::before {
        background-color: $base-color;
        border-color: $background-color;
      }

      &::after {
        color: $background-color;
        background-color: $base-color;
      }
    }

    &.from-left {
      &::before {
        box-shadow: -5px 10px 0 6px $base-color;
      }
      &::after {
        @include box-shadow($base-color);
      }
    }

    &.from-right {
      &::before {
        box-shadow: 5px 10px 0 6px $base-color;
      }
      &::after {
        @include box-shadow($base-color, false);
      }
    }
  }

  &.from-left {
    &::before,
    &::after {
      left: 2rem;
    }

    &::before {
      bottom: -14px;
      width: 26px;
      height: 10px;
      background-color: $background-color;
      border-right: 4px solid $base-color;
      border-left: 4px solid $base-color;
    }

    &::after {
      bottom: -18px;
      width: 18px;
      height: 4px;
      margin-right: 8px;
      color: $base-color;
      background-color: $background-color;
      @include box-shadow($background-color);
    }
  }

  &.from-right {
    &::before,
    &::after {
      right: 2rem;
    }

    &::before {
      bottom: -14px;
      width: 26px;
      height: 10px;
      background-color: $background-color;
      border-right: 4px solid $base-color;
      border-left: 4px solid $base-color;
    }

    &::after {
      bottom: -18px;
      width: 18px;
      height: 4px;
      margin-left: 8px;
      background-color: $background-color;
      @include box-shadow($background-color, false);
    }
  }
}
